package mygameserver;

import java.io.InputStreamReader;
import java.net.Socket;
import java.util.Scanner;

public class ServerThread implements Runnable {
    private Socket clSocket;
    static GameServer server;

    public ServerThread(Socket clientSocket, GameServer server) {
        this.server = server;
        clSocket = clientSocket;
    }

    @Override
    public void run() {
        boolean start = true;
        try {
            while (start) {
                Scanner in = new Scanner(new InputStreamReader(clSocket.getInputStream()));
                String getStr = "";
                getStr = in.nextLine();
                System.out.println("[from " + clSocket.hashCode() + "] : " + getStr);
                ServerCommands.receive(getStr, clSocket);
                start = !CommandsList.CLOSE_CONNECTION.getAbbr().equals(getStr);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void setStop(){

    }

}
